<template>
  <div class="header wrap">
    <div class="logo">
      <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
    </div>
    <nav>
      <ul class="navs">
        <li
          @click="$router.push('/home')"
          :class="{ current: $route.path == '/home' }"
        >
          首页
        </li>
        <li
          @click="$router.push('/goods')"
          :class="{ current: $route.path == '/goods' }"
        >
          全部商品
        </li>
        <li
          @click="$router.push('/user')"
          :class="{ current: $route.path == '/user' }"
        >
          个人中心
        </li>
        <li
          @click="$router.push('/order')"
          :class="{ current: $route.path == '/order' }"
        >
          我的订单
        </li>
        <li
          @click="$router.push('/free')"
          :class="{ current: $route.path == '/free' }"
        >
          专属福利
        </li>
      </ul>
    </nav>
    <div class="search">
      <input type="text" placeholder="输入关键字" v-model.trim="searchVal" />
      <span class="searchBtn" @click="searchFn">
        <img src="../assets/img/search.png" alt="" />
      </span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchVal: "",
    };
  },
  methods: {
    searchFn() {
      let searVal = this.searchVal;
      console.log({ searVal });
      this.$router.push(`/goods?keyword=${searVal}`);
    },
  },
};
</script>

<style lang="less" scoped>
.header {
  height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 15px auto 20px;
  .navs {
    display: flex;
    justify-content: space-between;
    width: 500px;
    font-size: 16px;
    font-weight: 500;

    color: #242b39;
    li {
      cursor: pointer;
    }
    .current {
      color: #0a328e;
      font-weight: 700;
    }
  }
  .search {
    display: flex;
    height: 40px;
    input {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      box-sizing: border-box;
      outline: none;
      text-indent: 1em;
    }
    .searchBtn {
      width: 50px;
      height: 40px;
      line-height: 40px;
      text-align: center;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
    }
  }
}
</style>